//
//  RBDZTabBarController.m
//  rubaoduanzi
//
//  Created by 李云飞 on 16/9/13.
//  Copyright © 2016年 liyunfei. All rights reserved.
//

#import "RBDZTabBarController.h"
#import "RBDZNavigationController.h"
#import "RBDZImage.h"
#import "RBDZHomeViewController.h"
#import "RBDZJokeViewController.h"
#import "RBDZFindViewController.h"
#import "RBDZPictureViewController.h"
#import "RBDZVideoViewController.h"
@interface RBDZTabBarController ()

@end

@implementation RBDZTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    RBDZHomeViewController *home=[[RBDZHomeViewController alloc]init];
    [self addChildController:home andTitle:@"首页" andImage:@"tab_sy" andSelectedImage:@"tab_sy_pre"];
    RBDZJokeViewController *joke=[[RBDZJokeViewController alloc]init];
    [self addChildController:joke andTitle:@"笑话" andImage:@"tab_xh" andSelectedImage:@"tab_xh_pre"];
    RBDZFindViewController *find=[[RBDZFindViewController alloc]init];
    [self addChildController:find andTitle:@"发现" andImage:@"tab_fx" andSelectedImage:@"tab_fx_pre"];
    RBDZPictureViewController *picture=[[RBDZPictureViewController alloc]init];
    [self addChildController:picture andTitle:@"趣图" andImage:@"tab_qt" andSelectedImage:@"tab_qt_pre"];
    RBDZVideoViewController *video=[[RBDZVideoViewController alloc]init];
    [self addChildController:video andTitle:@"视频" andImage:@"tab_sp" andSelectedImage:@"tab_sp_pre"];
}
-(void)addChildController:(UIViewController *)controller andTitle:(NSString *)title andImage:(NSString *)image andSelectedImage:(NSString *)selectedImage{
    RBDZNavigationController *na=[[RBDZNavigationController alloc]initWithRootViewController:controller];
    na.tabBarItem.image=[RBDZImage imageWithRendering:image];
    na.tabBarItem.selectedImage=[RBDZImage imageWithRendering:selectedImage];
    na.tabBarItem.title=title;
    NSMutableDictionary *dictF=[NSMutableDictionary dictionary];
    dictF[NSFontAttributeName]=[UIFont systemFontOfSize:13];
    [na.tabBarItem setTitleTextAttributes:dictF forState:UIControlStateNormal];
    NSMutableDictionary *dictC=[NSMutableDictionary dictionary];
    dictC[NSForegroundColorAttributeName]=(__bridge id _Nullable)([[UIColor colorWithRed:0/255.0 green:176/255.0 blue:61/255.0 alpha:1]CGColor]);
    [na.tabBarItem setTitleTextAttributes:dictC forState:UIControlStateSelected];
    [self addChildViewController:na];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
